from dataclasses import dataclass
from typing import Optional


@dataclass
class SmsUpConfigData:
    """短信上行配置响应数据"""
    SmsUpContent: str  # 短信上行内容
    SmsUpNumber: str  # 短信上行号码


@dataclass
class SmsUpConfigResponse:
    """获取短信上行配置响应"""
    Code: int  # 状态码，0表示成功
    Msg: str  # 响应消息
    TipType: int  # 提示类型
    Data: Optional[SmsUpConfigData] = None  # 响应数据
    
    @classmethod
    def from_dict(cls, data: dict):
        """从字典创建响应对象"""
        response_data = None
        if data.get('Data'):
            response_data = SmsUpConfigData(
                SmsUpContent=data['Data'].get('SmsUpContent', ''),
                SmsUpNumber=data['Data'].get('SmsUpNumber', '')
            )
            
        return cls(
            Code=data.get('Code', -1),
            Msg=data.get('Msg', ''),
            TipType=data.get('TipType', 0),
            Data=response_data
        )
